import { ref } from "vue";
import axios from "axios";
interface Positioning {
    address: string;
    content: {
        address: string; //简要信息
        address_detail: {
            adcode: string;
            city: string; //市
            city_code: number;
            district: string; //县
            province: string; //省
            street: string;
            street_number: string;
        };
        point: {
            x: string;
            y: string;
        };
    };
    status: number;
}
//百度地图api ak密钥
const ak = "ZWKH6dNYYPIAmBoS9cuJuDZuTf7PB8pO"


const param = ref({
    ip: "",
    ak: ak,
    coor: "bd09ll",
});
//静态网址?直接返回请求的ip公网
const api64Url = "http://httpbin.org/ip";

const getLocation = async () => {
    // //获取用户公网ip
    await axios.get(api64Url).then((response) => {
        param.value.ip = response.data.origin;
    });
    const data = await axios({ url: "/baidu_api/location/ip", method: "get", params: param.value })
    return data.data.content
};

export { getLocation };